package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhHolder;
import com.laowang.project.system.service.MyCyhHolderService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 车友会股东配置Controller
 * 
 * @author laowang
 * @date 2024-03-21
 */
@Api(tags = "车友会股东配置接口")
@RestController
@RequestMapping("/holder")
public class MyCyhHolderController extends BaseController {
    @Autowired
    private MyCyhHolderService myCyhHolderService;

    /**
     * 查询车友会股东配置列表
     */
    @ApiOperation(value = "查询车友会股东配置列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhHolder myCyhHolder) {
        startPage();
        List<MyCyhHolder> list = myCyhHolderService.selectMyCyhHolderList(myCyhHolder);
        return getDataTable(list);
    }
    
    /**
     * 导出车友会股东配置列表
     */
    @ApiOperation(value = "导出车友会股东配置列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:export')")
    @Log(title = "车友会股东配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhHolder myCyhHolder) {
        List<MyCyhHolder> list = myCyhHolderService.selectMyCyhHolderList(myCyhHolder);
        ExcelUtil<MyCyhHolder> util = new ExcelUtil<MyCyhHolder>(MyCyhHolder.class);
        return util.exportExcel(list, "holder");
    }

    /**
     * 获取车友会股东配置详细信息
     */
    @ApiOperation(value = "获取车友会股东配置详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhHolderService.selectMyCyhHolderById(id));
    }

    /**
     * 新增车友会股东配置
     */
    @ApiOperation(value = "新增车友会股东配置",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:add')")
    @Log(title = "车友会股东配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhHolder myCyhHolder) {
        return toAjax(myCyhHolderService.insertMyCyhHolder(myCyhHolder));
    }

    /**
     * 修改车友会股东配置
     */
    @ApiOperation(value = "修改车友会股东配置",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:edit')")
    @Log(title = "车友会股东配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhHolder myCyhHolder) {
        return toAjax(myCyhHolderService.updateMyCyhHolder(myCyhHolder));
    }

    /**
     * 删除车友会股东配置
     */
    @ApiOperation(value = "删除车友会股东配置",notes = "")
    @PreAuthorize("@ss.hasPermi('my:holder:remove')")
    @Log(title = "车友会股东配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhHolderService.deleteMyCyhHolderByIds(ids));
    }
}
